#pragma once

#include <stdarg.h>

enum LogLevel
{
	LEVEL_ERROR,
	LEVEL_WARN,
	LEVEL_INFO,
	LEVEL_DEBUG,
	LEVEL_TRACE,
};

#define LOG_ERROR(str, args, ...) do { SpyLog(LEVEL_ERROR, str, ##args); } while (false)
#define LOG_WARN(str, args, ...) do { SpyLog(LEVEL_WARN, str, ##args); } while (false)
#define LOG_INFO(str, args, ...) do { SpyLog(LEVEL_INFO, str, ##args); } while (false)
#define LOG_DEBUG(str, args, ...) do { SpyLog(LEVEL_DEBUG, str, ##args); } while (false)
#define LOG_TRACE(str, args, ...) do { SpyLog(LEVEL_TRACE, str, ##args); } while (false)



inline void SpyLog(LogLevel, const char *str, ...)
{
	char buffer[1024];

	va_list ap;
	va_start(ap, str);
	vsnprintf(buffer, sizeof(buffer), str, ap);
	va_end(ap);
#ifdef _SERVER
	TRACE(buffer);
#endif
}